package com.ltv.xiangqiplugin.views;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.Panel;
import java.awt.TextArea;
import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;

public class HtmlView extends JFrame {
	private TextArea html = new TextArea();

	public HtmlView() {
		Panel localPanel = new Panel(new GridLayout(1, 1, 1, 1));
		localPanel.add(html);
		getContentPane().add(BorderLayout.CENTER, localPanel);

		setSize(1000, 600);
		requestFocus();
		
		addWindowListener(new WindowAdapter() {

			@Override
			public void windowClosing(WindowEvent e) {
				setVisible(false);
			}
			
		});
		
		centerScreen();
	}
	
	public void setHtmlText(String htmlText) {
		html.setText(htmlText);
		setVisible(true);
	}
	
	private void centerScreen() {
		int x = (Toolkit.getDefaultToolkit().getScreenSize().width - getWidth())/2;
		int y = (Toolkit.getDefaultToolkit().getScreenSize().height - getHeight())/2;
		
		setLocation(x, y);
	}
}